package com.wdc.deliveryrobot.utils;

import android.util.Log;

import com.sirui.selfstudysdk.main.SelfChassisState;
import com.wdc.deliveryrobot.constant.Constants;
import com.wdc.deliveryrobot.event.RobotSendEvent;

import org.greenrobot.eventbus.EventBus;

//运动工具
public class RunUtils {


    public static void Send(float x,float y,float z){
        SelfChassisState.getInstance().linePatrolNaxvigation(x,y,z);
        while (true) {
            //状态等于0开始出发
            if (SelfChassisState.getInstance().getResult() == 0){
                Log.d("TaskActivity","TaskActivity 出发");
                EventBus.getDefault().post(new RobotSendEvent(RobotSendEvent.PREPARE));
                break;
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
        new Thread(()->{
            while (true) {
                if (SelfChassisState.getInstance().getResult() == 1 || SelfChassisState.getInstance().getResult() == -2) {
                    switch (Constants.TASK_NOW){
                        case 1:
                            Log.d("TaskActivity","TaskActivity 到达");
                            EventBus.getDefault().post(new RobotSendEvent(RobotSendEvent.ARRIVE));
                            break;
                    }
                    break;
                }
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();
    }
}
